#include "common.h"

int _prev = -pow(2, 31);
int n = 0;
bool is = true;
void dfs(TreeNode* root)
{
	if (root == nullptr || is == false) return;
	dfs(root->left);
	if (n == 0 && _prev == root->val);
	else if (_prev >= root->val)
	{
		is = false;
		return;
	}
	_prev = root->val;
	n++;
	dfs(root->right);
}
bool isValidBST(TreeNode* root)
{
	dfs(root);
	return is;
}
